<template>
	<!-- #ifdef APP-PLUS -->
	<nav-bars backState="1000" bgColor="#fff" fontColor="#000" title="全景图设计"></nav-bars>
	<!-- #endif -->
	<web-view :webview-styles="webviewStyles" :src="url"></web-view>
</template>

<script>

import service_mall from '@/service/mall.js'
import service_design from '@/service/design';
export default {
	
	data() {
		return {
		 url:'',
		 urls:'',
		 userId:'',
		}
	},
	onLoad(e) {
		this.$utils.getUrl()
		
		let scene = decodeURIComponent(e.scene);
		scene = scene.split('&');
		let obj = {};
		for (let i = 0; i < scene.length; i++) {
			let newscene = scene[i].split('=');
			obj[newscene[0]] = newscene[1];
		}
		// 分享动态的时候二维码参数过长时 二次获取二维码参数
		if(obj.scene){
			console.log(obj.scene,'扫小程序码的参数')
			this.getShareData(obj)
		}
		
		let token = uni.getStorageSync('token')
		if(e.share_uid){
			let shareuId= e.share_uid
			this.$store.commit('index/SET_shareuId', shareuId)
			if(token && shareuId){
				service_mall.getPromoter({share_uid:shareuId})
					.then(res => {
				})
			}
		}
		this.userId = uni.getStorageSync('userId')
		if(!obj.scene){
			this.urls = e.url
			this.url = decodeURIComponent(e.url)
		}
	},
	onShareAppMessage(res) {
		let that = this
		if (res.from === 'button') {}
		return {
		  title: '全景图设计',
		  path: '/pages_3D/pages/3D/panorama?url=' + this.urls + '&share_uid='+ this.userId,
		  success: function (res) {
			
		  }
		}  
	},
	methods: {
		// 二维码参数过长 获取二维码参数
		async getShareData(obj){
			const that = this
			let token = uni.getStorageSync('token')
			let res = await service_design.getShareQrParams({scene:obj.scene})
			console.log(res,'获取的微信小程序码的参数')
			if(res.code==1){
				if(!res.data.url){
					uni.showToast({
						title:'暂无3D方案',
						icon:'none'
					})
					setTimeout(()=>{
						uni.switchTab({
							url:'/pages/home/index/index'
						})
					},1000)
				}
				that.urls = encodeURIComponent(res.data.url)
				that.url = res.data.url
				// console.log(that.url,that.urls,'000000');
			}
		},
	}
}
</script>

<style lang="scss" scoped>


</style>